//
//  JZHFBViewController.m
//  极致荟
//
//  Created by hetao on 14-9-13.
//  Copyright (c) 2014年 mac. All rights reserved.
//

#import "JZHFBViewController.h"

@interface JZHFBViewController ()

@end

@implementation JZHFBViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}


- (id)initOuser:(OtherUsers *)ouser
{
    JZHFBViewController *jzh=[[JZHFBViewController alloc] init];
    jzh.ouser=ouser;
    return jzh;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.navigationItem.title=@"详细资料";
    UIButton *leftButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 12, 20)];
    [leftButton addTarget:self action:@selector(leftDrawerButtonPress:) forControlEvents:UIControlEventTouchUpInside];
    [leftButton setImage:[UIImage imageNamed:@"返回"] forState:UIControlStateNormal];
    UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
    self.automaticallyAdjustsScrollViewInsets=NO;
    self.navigationItem.leftBarButtonItem = leftBarButton;
    self.name.text=self.ouser.name;
    self.city.text=[self.ouser.locationdic objectForKey:@"cityName"];
    self.ispax.text=self.ouser.isStr;
    [ImageCache imageUrl:self.ouser.userHeadImage UiImageview:self.headimage];
    [self vipiconimage];
    [self.name sizeToFit];
    [self.ispax sizeToFit];
    [self.vipicon setFrame:CGRectMake(self.name.frame.origin.x+5+self.name.frame.size.width, self.vipicon.frame.origin.y, self.vipicon.frame.size.width, self.vipicon.frame.size.height )];
}
//会员图标显示设置
- (void)vipiconimage
{
    int vip=self.ouser.vip;
    if(vip==0)
    {
        if(self.ouser.sex==1)
        {
            self.vipicon.image=[UIImage imageNamed:@"no1-1"];
        }else
        {
            self.vipicon.image=[UIImage imageNamed:@"no0-1"];
        }
        
        return;
    }
    
    if(vip==1)
    {
        self.vipicon.image=[UIImage imageNamed:@"vip1-1"];
    }else
    {
        self.vipicon.image=[UIImage imageNamed:@"vip2-1"];
    }
}

- (void)leftDrawerButtonPress:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)guanz:(id)sender
{
    NSDictionary *dic=[[NSDictionary alloc]initWithObjectsAndKeys:[NSNumber numberWithInt:self.ouser.userId],@"attentionId",[NSNumber numberWithInt:[User defuceUser].userId],@"userId", nil];
    [HttpRequest httpRequestPost:JZHHTTPURL(@"friends/attentionFriend") parameters:dic block:^(id data, HttpReturnCode rerurncode) {
        if(rerurncode==0)
        {
            [MMProgressHUD showSuccessWithTips:@"关注成功"];
            [self.navigationController popViewControllerAnimated:YES];
        }else
        {
            [MMProgressHUD showInformationWithTips:@"关注失败"];
        }
    }];
}
@end
